<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<p>傻逼${cid}</p>
<p>${request}</p>
<p>获取不了request的URL怎么破呢？</p>
</body>

<script src="/static/jQuery/jquery-2.2.3.min.js"></script>
<script>
    $(function (){
        var socket;
        if(typeof (WebSocket) == "undefined"){
            console.log("你的浏览器不支持WebSocket");
        }else{
            console.log("你的浏览器支持WebSocket");
            //实现化WebSocket对象，指定要连接的服务器地址与端口，建立连接
            //等同于
            socket = new WebSocket("ws://localhost:8787/websocket/${cid}");
            //打开事件
            socket.onopen = function (ev) {
                console.log("Socket 已打开" + ev);
                //socket.send("这是来自客户端的消息" + location.href + new Date());
            }
            //获得消息事件
            socket.onmessage = function (ev) {
                console.log(ev.data);
            }
            //关闭事件
            socket.onclose = function () {
                console.log("Socket已关闭")
            }
            //发生错误时间
            socket.onerror = function (ev) {
                alert("Socket发生了错误");
                //此时可以尝试刷新页面
            }
        }
    })
</script>
</html>